package com.xt.purchasingsystem.controller;


import com.xt.purchasingsystem.dto.ExecutePurchaseDto;
import com.xt.purchasingsystem.dto.OutboundProcurementDto;
import com.xt.purchasingsystem.service.OutboundProcurementService;
import com.xt.purchasingsystem.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 采购出库所有接口
 * </p>
 *
 * @author yhp
 * @since 2020-06-06
 */
@RestController
@RequestMapping("/outboundProcurement")
public class OutboundProcurementController {
    @Autowired
    private OutboundProcurementService outboundProcurementService;

    /**
     * 添加出库采购及其出库采购明细的接口
     *
     * @param outboundProcurementDto
     * @return
     */
    @PostMapping
    public Result saveOutboundProcurement(@RequestBody OutboundProcurementDto outboundProcurementDto) {
        return outboundProcurementService.saveOutboundProcurement(outboundProcurementDto);
    }

    /**
     * 分页查询所有未生成采购计划单的出库采购及其明细的接口
     *
     * @param currNo
     * @param pageSize
     * @return
     */
    @GetMapping("/{currNo}/{pageSize}")
    public Result getAllNoPurchaseByPage(@PathVariable Integer currNo, @PathVariable Integer pageSize) {
        return outboundProcurementService.getAllNoPurchaseByPage(currNo, pageSize);
    }

    /**
     * 修改出库采购拟采购总数和出库采购明细拟采购数量的接口
     *
     * @param outboundProcurementDto
     * @return
     */
    @PutMapping
    public Result updateOutboundProcurementAndDetailsPurchaseAmount(@RequestBody OutboundProcurementDto outboundProcurementDto) {
        return outboundProcurementService.updateOutboundProcurementAndDetailsPurchaseAmount(outboundProcurementDto);
    }

    /**
     * 采购出库单生成采购计划单的接口
     * @param executePurchaseDto
     * @return
     */
    @PutMapping("/executePurchase")
    public Result executePurchase(@RequestBody ExecutePurchaseDto executePurchaseDto) {
        System.out.println(executePurchaseDto);
        return   outboundProcurementService.executePurchase(executePurchaseDto);
    }
}

